<template>
    <div class="destination-card" @click="navigateToDetail">
        <!-- 价格标签 -->
        <div class="price-tag">￥{{ destination.price }}起</div>

        <!-- 目的地图片 -->
        <img :src="destination.image" :alt="destination.name">

        <!-- 文字信息 -->
        <div class="card-content">
            <h3>{{ destination.name }}</h3>
            <p class="description">{{ destination.description }}</p>

            <!-- 标签区 -->
            <div class="tags">
                <span v-for="(tag, index) in destination.tags" :key="index"
                    :style="{ backgroundColor: tagColors[index % 4] }">
                    {{ tag }}
                </span>
            </div>

            <!-- 跳转按钮 -->
            <button class="explore-btn">
                探索详情 >
            </button>
        </div>
    </div>
</template>

<script>
import { useRouter } from 'vue-router'

export default {
    name: 'DestinationCard',
    props: {
        destination: {
            type: Object,
            required: true,
            default: () => ({
                id: '',
                name: '',
                price: 0,
                image: '',
                description: '',
                tags: []
            })
        }
    },
    setup(props) {
        const router = useRouter()
        const tagColors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#A37EBD']

        const navigateToDetail = () => {
            router.push({
                name: 'DestinationDetail',
                params: { id: props.destination.id }
            })
        }

        return {
            tagColors,
            navigateToDetail
        }
    }
}
</script>

<style scoped>
.destination-card {
    position: relative;
    width: 280px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s;
}

.destination-card:hover {
    transform: translateY(-5px);
}

.price-tag {
    position: absolute;
    top: 15px;
    left: 15px;
    background-color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: bold;
    color: #FF6B6B;
    z-index: 2;
}

img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.card-content {
    padding: 15px;
}

h3 {
    margin: 10px 0 5px;
    font-size: 1.3rem;
}

.description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
    line-height: 1.5;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.tags span {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: white;
}

.explore-btn {
    width: 100%;
    padding: 8px 0;
    background: none;
    border: none;
    color: #45B7D1;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.explore-btn:hover {
    color: #FF6B6B;
}
</style>